## The Meggitt table of the ternary Golay code [11,6,5]_3


from PyM import *


n = 11; R = range(n-1); U = [1,-1]
RxUxU = [(i,u,v) for i in R for u in U for v in U]

[_,x] = polynomial_ring(Zn(3),'x')

g = x**5+x**4-x**3+x**2-1

# Megit table, as a list of pairs
E1 = [(remainder(u*x**(n-1),g),u*x**(n-1)) for u in U]

E2 = [(remainder(u*x**(n-1)+v*x**i,g),u*x**(n-1)+v*x**i) for (i,u,v) in RxUxU]

E = E1+E2

def lookup(k,T):
    for (a,b) in T:
        if a==k: return b
    return 0

# Example
s = remainder(-x**(n-1)+x**6,g)

show(s)

show(lookup(s,E))